<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>批量修改</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="/static/css/font.css">
        <link rel="stylesheet" href="/static/css/xadmin.css">
        <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/js/xadmin.js"></script>
		<script type="text/javascript" src="/static/js/jquery.min.js"></script>
		<script type="text/javascript" src="/static/js/jquery.form.js"></script>
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="x-nav">
          <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
						<form class="layui-form" id="signupForm" action="{:url('shop/goods/amends')}" method="post">
							<div class="layui-card-header">批量改价</div>
							<div class="layui-card-body ">
								<table class="layui-table layui-form">
								  <thead>
									<tr>
									  <th>产品名称</th>
									  <th>零售单价（元）</th>
									  <th>批发价（元）</th>
								  </thead>
								  <tbody>
									{volist name="goodslist" id="vo"}
									<tr>
									  <td><input type="hidden" name="goods_id[]" value="{$vo.goods_id}"/>{$vo.goods_name}</td>
									  <td><input type="text" name="selling_price[]" class="layui-input" value="{$vo.selling_price}"></td>
									  <td><input type="text" name="trade_price[]" class="layui-input" value="{$vo.trade_price}"></td>
									</tr>
									{/volist}
								  </tbody>
								</table>
							</div>
							<div class="layui-card-header">
								<button  class="layui-btn" lay-filter="edit" lay-submit="">编辑确认</button>
							</div>
						</form>
                    </div>
                </div>
            </div>
        </div> 
    </body>
    <script>
	var flag = true;
	layui.use(['form', 'layer'],
		function() {
			$ = layui.jquery;
			var form = layui.form,
			layer = layui.layer;

			//监听提交
			form.on('submit(edit)',
			function(data) {
				if(flag)
				{
					flag = false;
					$("#signupForm").ajaxSubmit(function (message) {
						console.log(message);
						 if(message.code == 10001)
						 {
							layer.msg("编辑成功", {
								icon: 6
							},
							function() {
								//关闭当前frame
								xadmin.close();
								// 可以对父窗口进行刷新 
								xadmin.father_reload();
							});
						 }else{
							layer.msg(message.msg, {
								icon: 5
							},
							function() {
								//关闭当前frame
								xadmin.close();
								// 可以对父窗口进行刷新 
								xadmin.father_reload();
							});
						 }
					});
				}else{
					layer.msg('正在提交。。。', {icon: 6});
				}
				return false;
			});
		});
	</script>
</html>